package com.fresher.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionController {
	@ExceptionHandler(Exception.class)
	public ModelAndView handleAllException(HttpServletRequest request, Exception exception) {
		ModelAndView model = new ModelAndView();
	    model.addObject("exception", exception);
	    model.addObject("url", request.getRequestURL());
	    model.setViewName("error");
	    return model;
	}
	
}
